# _*_ coding:utf-8 _*_
# @Time  : 2022.06.17
# @Author: zizlee
import json

import requests

r = requests.get('http://210.13.218.130:9000/v1/ruizy/variety/')
variety_list = r.json()['data']

vl = []
for v in variety_list:
    print(v)
    if v['is_real']:
        vl.append({
            'variety_en': v['variety_en'],
            'ex': v['exchange_name'],
            'variety_name': v['variety_name'],
            'unit': v['price_unit']
        })

vl.sort(key=lambda x: x['variety_en'])
with open('v.json', 'w', encoding='utf8') as fp:
    json.dump(vl, fp, ensure_ascii=False)